﻿@model CompanyListViewModel
@using DiplomaWeb.Models.CompaniesAndLecturers
<script type="text/javascript" language="javascript">
    function DeleteCompany(companyId) {
        var path = '@Url.RouteUrl("Default", new {controller = "SystemManagers", action = "DeleteCompany"})';
        $.ajax({
            url: path,
            type: "POST",
            async: false,
            data: ({ companyId: companyId }),
            success: function () {
                $("#" + companyId).remove();
            }
        });
    }

    function GetCompanyDetails(companyId) {
        var path = '@Url.RouteUrl("Default", new {controller = "SystemManagers", action = "GetCompanyDetails"})';
        $.ajax({
            url: path,
            type: "POST",
            async: false,
            data: ({ companyId: companyId }),
            success: function (response) {
                $("#propertiesList").html(response);
            }
        });
    }
</script>
@foreach (CompanyViewModel item in Model.Companies) {
<div id="@item.Id">
    <img src="@Url.Content("~/Content/Icons/delete.png")" class="mediumIcon" onclick="DeleteCompany('@item.Id');" />
    <img src="@Url.Content("~/Content/Icons/edit.png")" class="mediumIcon" onclick="GetCompanyDetails('@item.Id');" /> 
    <span class="mediumBoldText">
        @item.Name
    </span>
</div>
}